{
  "name": "Enrich HubSpot Companies: Firmographics, tech & AI-powered custom attributes",
  "nodes": [
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5.1",
          "cachedResultName": "gpt-5.1"
        },
        "options": {}
      },
      "id": "57a7027e-5ff8-4842-875f-98b264609a4b",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        448,
        1056
      ],
      "typeVersion": 1.2
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n  \"website_name\": \"string\",\n  \"website_domain\": \"string\",\n  \"key_positioning_elements\": [\"string\"],\n  \"target_audience\": \"string\",\n  \"competitive_positioning_statement\": \"string\",\n  \"summary\": \"string\",\n  \"feature_1\": \"string\",\n  \"feature_2\": \"string\",\n  \"feature_3\": \"string\",\n  \"pricing_model\": \"string\",\n  \"list_of_prices\": [\"string\"],\n  \"list_of_pros\": [\"string\"],\n  \"list_of_cons\": [\"string\"],\n  \"personas_mentioned\": [\"string\"],\n  \"value_propositions\": [\"string\"],\n  \"results\": [\"string\"]\n}"
      },
      "id": "d0e873c5-28bd-483c-9a60-159034db8e8b",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        640,
        1056
      ],
      "typeVersion": 1.3
    },
    {
      "parameters": {
        "url": "https://api2.sonalabs.com/resource/company/enrich",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "website",
              "value": "={{ $json.website_domain.toLowerCase() + (/\\.[a-z]{2,}$/i.test($json.website_domain.toLowerCase()) ? '' : '.com') }}"
            }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key"
            },
            {
              "name": "content-type",
              "value": "application/json"
            },
            {
              "name": "accept",
              "value": "application/json"
            }
          ]
        },
        "options": {}
      },
      "id": "a610a3c6-f1d8-4793-953e-1df7832bd9b8",
      "name": "Sona Enrich",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1952,
        944
      ],
      "typeVersion": 4.2,
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {},
      "id": "23da8e19-3666-497f-a62a-a5ce086dadd1",
      "name": "End",
      "type": "n8n-nodes-base.noOp",
      "position": [
        2080,
        848
      ],
      "typeVersion": 1
    },
    {
      "parameters": {},
      "id": "c24d4022-0315-4d77-abf4-b7d0fb635009",
      "name": "Start",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -224,
        832
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "## 📥 Step 1: Data Input & Web Scraping\n\n**What happens here:**\n\n- Reads company domains from Google Sheets\n- Scrapes each website's content\n- Extracts and cleans main content\n- Removes navigation, footers, and noise",
        "height": 752,
        "width": 640
      },
      "id": "1c4fd953-5246-4977-a5fc-0c2c81a6fd84",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -272,
        592
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1qUir1c-_ScMnoYVoQ0W41nsv5IpLW6rjK8HUNqvNnAg",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1qUir1c-_YOUR_AWS_SECRET_KEY_HERE?usp=drivesdk",
          "cachedResultName": "example"
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1qUir1c-_YOUR_AWS_SECRET_KEY_HERE#gid=0",
          "cachedResultName": "Sheet1"
        },
        "options": {}
      },
      "id": "eaec507c-cfe7-40bf-9742-0a657e05b908",
      "name": "Get Company List from Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -32,
        832
      ],
      "typeVersion": 4.6
    },
    {
      "parameters": {
        "url": "={{ ($json['Website Domain'].match(/^https?:\\/\\//) ? $json['Website Domain'] : 'https://' + $json['Website Domain']).toLowerCase() }}",
        "options": {
          "batching": {
            "batch": {
              "batchSize": 1,
              "batchInterval": 2000
            }
          }
        }
      },
      "id": "624634f5-9067-4637-84dd-4a7c7709a20b",
      "name": "Scrape Website Content",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        160,
        832
      ],
      "typeVersion": 4.2
    },
    {
      "parameters": {
        "operation": "extractHtmlContent",
        "extractionValues": {
          "values": [
            {
              "key": "main_content",
              "cssSelector": "main, body, article, .main-content, #content, p",
              "skipSelectors": "script, img, style, nav, footer, header"
            }
          ]
        },
        "options": {}
      },
      "id": "7ca12dbf-bb31-4836-b471-f4d389672275",
      "name": "Extract HTML Content",
      "type": "n8n-nodes-base.html",
      "position": [
        -144,
        1088
      ],
      "typeVersion": 1.2
    },
    {
      "parameters": {
        "jsCode": "// Get all items from the input\nconst items = $input.all();\n\n// Get all website domains from the sheet\nconst sheetData = $('Get Company List from Sheet').all();\n\n// Process each item and match it with the corresponding website domain by index\nconst results = items.map((item, index) => {\n  const text = item.json.main_content;\n  \n  // Split into lines and filter out noise\n  const lines = text.split('\\n').filter(line => {\n    const trimmed = line.trim();\n    \n    // Skip empty lines\n    if (!trimmed) return false;\n    \n    // Skip common noise patterns\n    if (trimmed.match(/^(Sign In|Book a Demo|Continue|Start for Free|Get a|Learn More)$/i)) return false;\n    if (trimmed.includes('javascript:void')) return false;\n    if (trimmed.includes('Thank you! Your submission')) return false;\n    if (trimmed.includes('Oops! Something went wrong')) return false;\n    if (trimmed.match(/^\\[.*?\\]$/)) return false; // Remove [links]\n    if (trimmed.match(/^(©|Terms and conditions|Privacy Policy)/)) return false;\n    if (trimmed.match(/^(LinkedIn|Twitter|Facebook)$/)) return false;\n    if (trimmed.length < 10) return false; // Skip very short lines\n    \n    return true;\n  });\n  \n  // Join back and clean up excessive whitespace\n  const cleaned = lines.join('\\n').replace(/\\n{3,}/g, '\\n\\n').trim();\n  \n  return { \n    json: { \n      main_content: cleaned,\n      website_domain: sheetData[index].json['Website Domain']\n    } \n  };\n});\n\nreturn results;"
      },
      "id": "b68d58bc-87b9-41a0-92a2-08c4095a2400",
      "name": "Clean & Format Text",
      "type": "n8n-nodes-base.code",
      "position": [
        112,
        1088
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Analyze the following scraped website content and extract structured information. Respond ONLY in valid JSON format with no preamble, no markdown backticks, and no additional text.\n\n**Content to analyze:**\n{{ $json.main_content }}\n\n**Required JSON structure:**\n```json\n{\n  \"website_name\": \"Name of the website\"\n  \"website_domain\": \"{{ $json.website_domain }}\"\n  \"key_positioning_elements\": [\"element 1\", \"element 2\", \"element 3\"],\n  \"target_audience\": \"Description of the target audience\",\n  \"competitive_positioning_statement\": \"A clear statement of how this product/service positions itself against competitors\",\n  \"summary\": \"Brief 2-3 sentence summary of what this company/product does\",\n  \"feature_1\": \"First major feature or capability\",\n  \"feature_2\": \"Second major feature or capability\",\n  \"feature_3\": \"Third major feature or capability\",\n  \"pricing_model\": \"Description of pricing model (e.g., freemium, subscription, enterprise, usage-based)\",\n  \"list_of_prices\": [\"price tier 1\", \"price tier 2\", \"price tier 3\"],\n  \"list_of_pros\": [\"pro 1\", \"pro 2\", \"pro 3\"],\n  \"list_of_cons\": [\"con 1\", \"con 2\", \"con 3\"],\n  \"personas_mentioned\": [\"persona 1\", \"persona 2\", \"persona 3\"],\n  \"value_propositions\": [\"value prop 1\", \"value prop 2\", \"value prop 3\"],\n  \"results\": [\"result/outcome 1\", \"result/outcome 2\", \"result/outcome 3\"]\n}\n```\n\n**Instructions:**\n- Extract information directly from the content provided\n- If information is not available, use \"Not mentioned\" or empty array []\n- For pros/cons, infer based on the benefits and potential limitations mentioned\n- For personas, identify job titles, roles, or departments mentioned (e.g., \"Marketing Leaders\", \"Sales Teams\", \"RevOps\")\n- For value propositions, identify the key benefits or outcomes promised\n- For results, extract any metrics, outcomes, or success stories mentioned\n- Keep responses concise and factual\n- Return ONLY the JSON object, nothing else",
        "hasOutputParser": true,
        "options": {}
      },
      "id": "0123da62-f5b5-483a-95e5-d0c695dceffa",
      "name": "Analyze with AI",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        448,
        880
      ],
      "typeVersion": 2.1
    },
    {
      "parameters": {
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "output"
            }
          ]
        },
        "options": {}
      },
      "id": "6ea235ef-a457-4f82-acae-7577029d6147",
      "name": "Collect AI Results",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        880,
        1168
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.hubapi.com/YOUR_AWS_SECRET_KEY_HERE",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "hubspotAppToken",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{\n  \"inputs\": [\n    {\n      \"name\": \"tech\",\n      \"label\": \"Sona: Tech\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"tech_categories\",\n      \"label\": \"Sona: Tech Categories\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"min_estimated_annual_revenue\",\n      \"label\": \"Sona: Min Estimated Annual Revenue\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"max_estimated_annual_revenue\",\n      \"label\": \"Sona: Max Estimated Annual Revenue\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"sub_industry\",\n      \"label\": \"Sona: Sub Industry\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"lat\",\n      \"label\": \"Sona: Latitude\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"lng\",\n      \"label\": \"Sona: Longitude\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"logo\",\n      \"label\": \"Sona: Logo\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"type\",\n      \"label\": \"Sona: Type\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"employees_range\",\n      \"label\": \"Sona: Employees Range\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"estimated_annual_revenue\",\n      \"label\": \"Sona: Estimated Annual Revenue\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"tags\",\n      \"label\": \"Sona: Tags\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"ips\",\n      \"label\": \"Sona: IPs\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"category\",\n      \"label\": \"Sona: Category\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"sub_category\",\n      \"label\": \"Sona: Sub Category\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"tagline\",\n      \"label\": \"Sona: Tagline\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"specialties\",\n      \"label\": \"Sona: Specialties\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"ads_30days\",\n      \"label\": \"Sona: Ads 30 Days\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"ads_365days\",\n      \"label\": \"Sona: Ads 365 Days\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"ads_ytd\",\n      \"label\": \"Sona: Ads YTD\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"social_handles\",\n      \"label\": \"Sona: Social Handles\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"linkedin_url\",\n      \"label\": \"Sona: LinkedIn URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"facebook_url\",\n      \"label\": \"Sona: Facebook URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"instagram_url\",\n      \"label\": \"Sona: Instagram URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"youtube_url\",\n      \"label\": \"Sona: YouTube URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"tiktok_url\",\n      \"label\": \"Sona: TikTok URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"pinterest_url\",\n      \"label\": \"Sona: Pinterest URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"github_url\",\n      \"label\": \"Sona: GitHub URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"discord_url\",\n      \"label\": \"Sona: Discord URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"telegram_url\",\n      \"label\": \"Sona: Telegram URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"reddit_url\",\n      \"label\": \"Sona: Reddit URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"snapchat_url\",\n      \"label\": \"Sona: Snapchat URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"medium_url\",\n      \"label\": \"Sona: Medium URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"twitch_url\",\n      \"label\": \"Sona: Twitch URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"crunchbase_url\",\n      \"label\": \"Sona: Crunchbase URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"g2_url\",\n      \"label\": \"Sona: G2 URL\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"founder_identifiers\",\n      \"label\": \"Sona: Founder Identifiers\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"num_founders\",\n      \"label\": \"Sona: Number of Founders\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"organic_keywords\",\n      \"label\": \"Sona: Organic Keywords\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"organic_traffic\",\n      \"label\": \"Sona: Organic Traffic\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"organic_cost\",\n      \"label\": \"Sona: Organic Cost\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"adwords_keywords\",\n      \"label\": \"Sona: AdWords Keywords\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"adwords_traffic\",\n      \"label\": \"Sona: AdWords Traffic\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"adwords_cost\",\n      \"label\": \"Sona: AdWords Cost\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"github_has_organization_projects\",\n      \"label\": \"Sona: GitHub Has Organization Projects\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"github_has_repository_projects\",\n      \"label\": \"Sona: GitHub Has Repository Projects\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"github_public_repos\",\n      \"label\": \"Sona: GitHub Public Repos\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"github_public_gists\",\n      \"label\": \"Sona: GitHub Public Gists\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"github_followers\",\n      \"label\": \"Sona: GitHub Followers\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"github_following\",\n      \"label\": \"Sona: GitHub Following\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"github_is_verified\",\n      \"label\": \"Sona: GitHub Is Verified\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"linkedin_id\",\n      \"label\": \"Sona: LinkedIn ID\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"key_positioning_elements\",\n      \"label\": \"AI: Key Positioning Elements\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"target_audience\",\n      \"label\": \"AI: Target Audience\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"competitive_positioning_statement\",\n      \"label\": \"AI: Competitive Positioning Statement\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"summary\",\n      \"label\": \"AI: Summary\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"feature_1\",\n      \"label\": \"AI: Feature 1\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"feature_2\",\n      \"label\": \"AI: Feature 2\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"feature_3\",\n      \"label\": \"AI: Feature 3\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"pricing_model\",\n      \"label\": \"AI: Pricing Model\",\n      \"type\": \"string\",\n      \"fieldType\": \"text\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"list_of_prices\",\n      \"label\": \"AI: List of Prices\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"list_of_pros\",\n      \"label\": \"AI: List of Pros\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"list_of_cons\",\n      \"label\": \"AI: List of Cons\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"personas_mentioned\",\n      \"label\": \"AI: Personas Mentioned\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"value_propositions\",\n      \"label\": \"AI: Value Propositions\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    },\n    {\n      \"name\": \"results\",\n      \"label\": \"AI: Results\",\n      \"type\": \"string\",\n      \"fieldType\": \"textarea\",\n      \"groupName\": \"companyinformation\"\n    }\n  ]\n}",
        "options": {}
      },
      "id": "6538196d-9539-4ea3-9ad7-cdd7f8c1b619",
      "name": "Create Custom HubSpot Fields",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1120,
        864
      ],
      "typeVersion": 4.2,
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "1c5ea36b-0283-4c38-a1c2-2329b2419fdb",
              "name": "output",
              "type": "array",
              "value": "={{ $('Collect AI Results').first().json.output }}"
            }
          ]
        },
        "options": {}
      },
      "id": "34436b67-515e-4177-b9d3-a0069848989d",
      "name": "Prepare Data for Loop",
      "type": "n8n-nodes-base.set",
      "position": [
        1328,
        864
      ],
      "typeVersion": 3.4
    },
    {
      "parameters": {
        "fieldToSplitOut": "output",
        "options": {}
      },
      "id": "20cb52b6-7953-4ee8-9131-d790f6907d17",
      "name": "Split Companies and AI Output into Items",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1520,
        864
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "2a5eea1b-eaef-490f-ad21-3dcffd9c02f3",
      "name": "Loop Through Companies",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1744,
        864
      ],
      "typeVersion": 3
    },
    {
      "parameters": {
        "authentication": "appToken",
        "resource": "company",
        "name": "={{ $json.data.name || $('Loop Through Companies').first().json.website_name }}",
        "additionalFields": {
          "annualRevenue": "={{ $json.data.annualRevenue || 0 }}",
          "city": "={{ $json.data.city || 'ywaa' }}",
          "companyDomainName": "={{ $('Loop Through Companies').item.json.website_domain || 'none' }}",
          "countryRegion": "={{ $json.data.country || 'none' }}",
          "description": "={{ $json.data.description || 'none' }}",
          "numberOfEmployees": "={{ $json.data.employees || 0 }}",
          "phoneNumber": "={{ $json.data.phone || 0 }}",
          "postalCode": "={{ $json.data.postalCode || 0 }}",
          "stateRegion": "={{ $json.data.state || 'none' }}",
          "streetAddress": "={{ $json.data.streetAddress || 'none' }}",
          "timezone": "={{ $json.data.timezone || 'none' }}",
          "twitterHandle": "={{ $json.data.twitterUrl || 'none' }}",
          "websiteUrl": "={{ $json.data.website || $('Loop Through Companies').first().json.website_domain || 'none' }}",
          "yearFounded": "={{ $json.data.founded || 0 }}"
        }
      },
      "id": "def37f82-2529-47a3-87d4-72b94744b8bd",
      "name": "Create HubSpot Company",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        1776,
        1168
      ],
      "typeVersion": 2.1
    },
    {
      "parameters": {
        "jsCode": "const sonaData = $('Sona Enrich').item.json.data;\nconst loopData = $('Loop Through Companies').item.json;\n\n// Format social handles nicely\nlet formattedSocialHandles = '';\nif (sonaData.socialHandles) {\n  try {\n    const socialHandlesObj = typeof sonaData.socialHandles === 'string' \n      ? JSON.parse(sonaData.socialHandles) \n      : sonaData.socialHandles;\n    \n    formattedSocialHandles = Object.entries(socialHandlesObj)\n      .filter(([key, value]) => value) // Only include non-empty values\n      .map(([key, value]) => `${key.charAt(0).toUpperCase() + key.slice(1)}: ${value}`)\n      .join('\\n');\n  } catch (e) {\n    formattedSocialHandles = sonaData.socialHandles;\n  }\n}\n\nreturn [{\n  json: {\n    properties: {\n      // Sona enrichment fields\n      tech: Array.isArray(sonaData.tech) ? sonaData.tech.join(', ') : sonaData.tech,\n      tech_categories: Array.isArray(sonaData.techCategories) ? sonaData.techCategories.join(', ') : sonaData.techCategories,\n      min_estimated_annual_revenue: sonaData.minEstimatedAnnualRevenue,\n      max_estimated_annual_revenue: sonaData.maxEstimatedAnnualRevenue,\n      sub_industry: sonaData.subIndustry,\n      lat: sonaData.lat,\n      lng: sonaData.lng,\n      logo: sonaData.logo,\n      employees_range: sonaData.employeesRange,\n      estimated_annual_revenue: sonaData.estimatedAnnualRevenue,\n      tags: Array.isArray(sonaData.tags) ? sonaData.tags.join(', ') : sonaData.tags,\n      ips: Array.isArray(sonaData.ips) ? sonaData.ips.join(', ') : sonaData.ips,\n      category: sonaData.category,\n      sub_category: sonaData.subCategory,\n      tagline: sonaData.tagline,\n      specialties: Array.isArray(sonaData.specialties) ? sonaData.specialties.join(', ') : sonaData.specialties,\n      ads_30days: sonaData.ads30days,\n      ads_365days: sonaData.ads365days,\n      ads_ytd: sonaData.adsYTD,\n      social_handles: formattedSocialHandles,\n      linkedin_url: sonaData.linkedinUrl,\n      facebook_url: sonaData.facebookUrl,\n      instagram_url: sonaData.instagramUrl,\n      youtube_url: sonaData.youtubeUrl,\n      tiktok_url: sonaData.tiktokUrl,\n      pinterest_url: sonaData.pinterestUrl,\n      github_url: sonaData.githubUrl,\n      discord_url: sonaData.discordUrl,\n      telegram_url: sonaData.telegramUrl,\n      reddit_url: sonaData.redditUrl,\n      snapchat_url: sonaData.snapchatUrl,\n      medium_url: sonaData.mediumUrl,\n      twitch_url: sonaData.twitchUrl,\n      crunchbase_url: sonaData.crunchbaseUrl,\n      g2_url: sonaData.g2Url,\n      founder_identifiers: Array.isArray(sonaData.founderIdentifiers) ? sonaData.founderIdentifiers.join(', ') : sonaData.founderIdentifiers,\n      num_founders: sonaData.numFounders,\n      organic_keywords: sonaData.organicKeywords,\n      organic_traffic: sonaData.organicTraffic,\n      organic_cost: sonaData.organicCost,\n      adwords_keywords: sonaData.adwordsKeywords,\n      adwords_traffic: sonaData.adwordsTraffic,\n      adwords_cost: sonaData.adwordsCost,\n      github_has_organization_projects: sonaData.githubHasOrganizationProjects,\n      github_has_repository_projects: sonaData.githubHasRepositoryProjects,\n      github_public_repos: sonaData.githubPublicRepos,\n      github_public_gists: sonaData.githubPublicGists,\n      github_followers: sonaData.githubFollowers,\n      github_following: sonaData.githubFollowing,\n      github_is_verified: sonaData.githubIsVerified,\n      linkedin_id: sonaData.linkedinId,\n      \n      // AI analysis fields\n      key_positioning_elements: Array.isArray(loopData.key_positioning_elements) ? loopData.key_positioning_elements.join('.\\n') : loopData.key_positioning_elements,\n      target_audience: loopData.target_audience,\n      competitive_positioning_statement: loopData.competitive_positioning_statement,\n      summary: loopData.summary,\n      feature_1: loopData.feature_1,\n      feature_2: loopData.feature_2,\n      feature_3: loopData.feature_3,\n      pricing_model: loopData.pricing_model,\n      list_of_prices: Array.isArray(loopData.list_of_prices) ? loopData.list_of_prices.join('\\n') : loopData.list_of_prices,\n      list_of_pros: Array.isArray(loopData.list_of_pros) ? loopData.list_of_pros.join('\\n') : loopData.list_of_pros,\n      list_of_cons: Array.isArray(loopData.list_of_cons) ? loopData.list_of_cons.join('\\n') : loopData.list_of_cons,\n      personas_mentioned: Array.isArray(loopData.personas_mentioned) ? loopData.personas_mentioned.join(', ') : loopData.personas_mentioned,\n      value_propositions: Array.isArray(loopData.value_propositions) ? loopData.value_propositions.join('\\n') : loopData.value_propositions,\n      results: Array.isArray(loopData.results) ? loopData.results.join('\\n') : loopData.results\n    }\n  }\n}];"
      },
      "id": "25c91d51-de7f-467b-a821-7def65a96096",
      "name": "Format Custom Properties",
      "type": "n8n-nodes-base.code",
      "position": [
        1952,
        1168
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "method": "PATCH",
        "url": "=https://api.hubapi.com/crm/v3/objects/companies/{{ $('Create HubSpot Company').first().json.companyId }}",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "hubspotAppToken",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ $json }}",
        "options": {}
      },
      "id": "9bb9d24a-d5a7-4eae-9357-7e1ea3cdd2a8",
      "name": "Update Company with AI Data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2128,
        1168
      ],
      "typeVersion": 4.2
    },
    {
      "parameters": {
        "content": "## 🤖 Step 2: AI Analysis\n\n**What happens here:**\n- Sends cleaned content to OpenAI\n- Extracts structured company intelligence\n- Identifies positioning, features, personas\n- Captures pricing, pros/cons, value props\n- Aggregates all AI results",
        "height": 752,
        "width": 640,
        "color": 4
      },
      "id": "436f96c9-b61c-46f0-bb96-5c59fb17d32a",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        384,
        592
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "## ⚙️ Step 3: HubSpot Preparation\n\n**What happens here:**\n- Creates custom fields in HubSpot CRM\n- Prepares AI-extracted data for import\n- Splits aggregated data into individual companies\n- Ready for batch processing",
        "height": 752,
        "width": 640,
        "color": 6
      },
      "id": "36ecc7d1-682a-4208-a54c-27ff8651fc4e",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1024,
        592
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "## 🔄 Step 4: Enrich & Sync to HubSpot\n\n**What happens here:**\n- Loops through each company one by one\n- Enriches with Sona API (firmographics, revenue, employees)\n- Creates company record in HubSpot\n- Formats and populates all custom fields\n- Combines AI insights + Sona data in one profile\n\n**💡 Get your Sona API key:** https://platform.sonalabs.com/onboardingv2",
        "height": 752,
        "width": 640,
        "color": 7
      },
      "id": "eb5c2ca0-8126-474a-8ff5-bc09387d7760",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1680,
        592
      ],
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Get Company List from Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sona Enrich": {
      "main": [
        [
          {
            "node": "Create HubSpot Company",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze with AI": {
      "main": [
        [
          {
            "node": "Collect AI Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Analyze with AI",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Collect AI Results": {
      "main": [
        [
          {
            "node": "Create Custom HubSpot Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean & Format Text": {
      "main": [
        [
          {
            "node": "Analyze with AI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract HTML Content": {
      "main": [
        [
          {
            "node": "Clean & Format Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Data for Loop": {
      "main": [
        [
          {
            "node": "Split Companies and AI Output into Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create HubSpot Company": {
      "main": [
        [
          {
            "node": "Format Custom Properties",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Through Companies": {
      "main": [
        [
          {
            "node": "End",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Sona Enrich",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Website Content": {
      "main": [
        [
          {
            "node": "Extract HTML Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Custom Properties": {
      "main": [
        [
          {
            "node": "Update Company with AI Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Analyze with AI",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Get Company List from Sheet": {
      "main": [
        [
          {
            "node": "Scrape Website Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Company with AI Data": {
      "main": [
        [
          {
            "node": "Loop Through Companies",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Custom HubSpot Fields": {
      "main": [
        [
          {
            "node": "Prepare Data for Loop",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Companies and AI Output into Items": {
      "main": [
        [
          {
            "node": "Loop Through Companies",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "availableInMCP": false
  },
  "versionId": "67e063a9-39c9-4026-aedd-83c0b66cc392",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "108ca395ced197c6477117d33be04fdbb054b19068f57471dcf11fcb19567da0"
  },
  "id": "ullZK5zc0t-Q5w-2B_z0n",
  "tags": []
}